//
//  BrandDetailBuyerCell.m
//  UGoods
//
//  Created by dllo on 16/1/23.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "BrandDetailBuyerCell.h"
#import "BaseView.h"
#import "BaseLabel.h"
#import "ConstantsDefine.h"
@interface BrandDetailBuyerCell ()
@property (nonatomic, retain) BaseView *backView;
@property (nonatomic, retain) UIView *lineView;
@end

@implementation BrandDetailBuyerCell

- (void)dealloc
{
    [_backView release];
    [_lineView release];
    [_buyerImageView release];
    [_buyerNameLabel release];
    [_briefLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[BaseView alloc] init];
        [self.contentView addSubview:_backView];
        [_backView release];
        
        self.buyerImageView = [[UIImageView alloc] init];
        _buyerImageView.layer.cornerRadius = 20;
        _buyerImageView.layer.borderWidth = 0.5;
        _buyerImageView.layer.borderColor = [UIColor blackColor].CGColor;
        _buyerImageView.layer.masksToBounds = YES;
        [self.backView addSubview:_buyerImageView];
        [_buyerImageView release];
        
        self.buyerNameLabel = [[BaseLabel alloc] init];
        //        _brandNameLabel.backgroundColor = [UIColor redColor];
        _buyerNameLabel.font = [UIFont systemFontOfSize:15 * WIDTH];
        _buyerNameLabel.textAlignment = NSTextAlignmentLeft;
        [self.backView addSubview:_buyerNameLabel];
        [_buyerNameLabel release];
        
        self.lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor grayColor];
        [self.backView addSubview:_lineView];
        [_lineView release];
        
        self.briefLabel = [[BaseLabel alloc] init];
        //        _descLabel.backgroundColor = [UIColor redColor];
        _briefLabel.numberOfLines = 0;
        _briefLabel.textColor = [UIColor grayColor];
        _briefLabel.font = [UIFont systemFontOfSize:13 * WIDTH];
        [self.backView addSubview:_briefLabel];
        [_briefLabel release];
        
    }
    return self;
}

// 计算buyerBriefLabel宽度
+ (CGFloat)heightWithText:(NSString *)text {
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(375 * WIDTH - 20 * WIDTH, 1000 * HEIGHT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13]} context:nil];
    
    return rect.size.height;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    self.buyerImageView.frame = CGRectMake(10 * WIDTH, 10 * HEIGHT, 40 * WIDTH, 40 * HEIGHT);
    self.buyerNameLabel.frame = CGRectMake(60 * WIDTH, 20 * HEIGHT, self.contentView.frame.size.width - 70 * WIDTH, 20 * HEIGHT);
    self.lineView.frame = CGRectMake(10 * WIDTH, 60 * HEIGHT, self.contentView.frame.size.width - 20 * WIDTH, 1);
    CGFloat h = [[self class] heightWithText:_briefLabel.text];
    self.briefLabel.frame = CGRectMake(10 * WIDTH, 70 * HEIGHT, self.contentView.frame.size.width - 20 * WIDTH, h * HEIGHT);
}


@end
